﻿@model IEnumerable<DAO.Product>
@{
    ViewBag.Title = "Index";
}
<style type="text/css">
    .rightMarg {
        margin-left:10px !important;
    }
    .height100 {
        height: 100% !important;
    }
</style>

    <div class="span3 height100">
        <div class="well sidebar-nav">
            <ul class="nav nav-list">
                <li class="nav-header">Список категорий товаров</li>
                <li>@Html.ActionLink("Все товары", "Index", new { id = 0 })</li>
                @foreach (DAO.Category cat in (List<DAO.Category>)ViewData["categories"])
                {
                    <li> 
                        @Html.ActionLink(cat.Name, "Index", new { id = cat.Id })
                    </li>
                }
            </ul>
        </div>
        <!--/.well -->
    </div>
    <!--/span-->

    <div class="container-fluid height100">
        <div class="row-fluid">

            <div class="span9 rightMarg">
                <div class="hero-unit">
                    @if (ViewData["cat_name"] != null)
                    {
                        <h2>
                            @ViewData["cat_name"]
                        </h2>
                    }
                    <table class="table table-hover">
                        <tr>
                            <th>Наименование товара
                            </th>
                            <th>Категория
                            </th>
                            <th>Количество
                            </th>
                            <th>Действия
                            </th>
                        </tr>
                        @*    <tr>
            <td>Все товары
            </td>
            <th>Товары всех категорий
            </th>
            <th>
                @Html.ActionLink("Details", "DetailsForAll")
            </th>
        </tr>*@
                 @*       @foreach (var item in Model)
                        {
                            <tr>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Name)
                                </td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Description)
                                </td>
                                <td>
                                    @Html.ActionLink("Details", "Details", new { id = item.Id })
                                </td>
                            </tr>
                        }*@

                        @foreach (DAO.Product pr in Model)
                        {
                            <tr>
                                <td>
                                    @pr.Name
                                </td>
                                <td>
                                    @pr.Category.Name
                                </td>
                                  <td>
                                   
                                    @if (pr.Count == null)
                                    {
                                        @:Нет в наличии
                                    }
                                    else if(pr.Count.Value == 0)
                                    {
                                        @:Нет в наличии
                                    }
                                    else
                                    {
                                       @pr.Count.Value
                                    }
                                </td>
                                <td>
                                    @Html.ActionLink("Details", "Details", new { id = pr.Id })
                                </td>
                            </tr>
                        }

                    </table>
                </div>
            </div>
        </div>

    </div>
